<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>瀑布流</title>
    <style>
      html,
      body {
        height: 100%;
      }
      #container {
        column-width: 25%;
        column-gap: 10px;
      }
      .child {
        /* width: 25%; */
        box-sizing: border-box;
        border: 1px solid red;
      }
    </style>
  </head>
  <body>
    <div id="container"></div>
    <script>
      const container = document.querySelector('#container')
      new Array(1000).fill().forEach(() => {
        const child = document.createElement('div')
        child.classList.add('child')
        child.style.height = 20 + Math.random() * 50 + 'px'
        container.appendChild(child)
      })
    </script>
  </body>
</html>
